import 'dart:io';

import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/widgets/button/normal_button.dart';
import 'package:finance_app/src/widgets/input/input_field.dart';
import 'package:flutter/material.dart';

import 'default_bottom_sheet.dart';

/// 添加员工
///
/// 返回员工的名字
showAddEmployeeBottomSheet(
  BuildContext context,
) =>
    showDefaultBottomSheet(context,
        child: _AddEmployeeWidget(),
        isScrollControlled: true,
        title: S.current.add_employee);

class _AddEmployeeWidget extends StatefulWidget {
  const _AddEmployeeWidget({Key key}) : super(key: key);

  @override
  __AddEmployeeWidgetState createState() => __AddEmployeeWidgetState();
}

class __AddEmployeeWidgetState extends State<_AddEmployeeWidget> {
  TextEditingController inputController = TextEditingController();

  void onAdd() {
    Navigator.of(context).pop(inputController.text);
  }

  @override
  void dispose() {
    super.dispose();
    inputController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        SizedBox(
          height: getDp(38),
        ),
        InputField(
          tip: S.current.enter_employee_name,
          controller: inputController,
        ),
        SizedBox(
          height: getDp(30),
        ),
        NormalButton(
          onTap: onAdd,
          title: S.current.add,
        ),
      ],
    );
  }
}
